<?php /* Smarty version 2.6.20, created on 2016-07-19 15:25:18
         compiled from brand.htm */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'count', 'brand.htm', 163, false),)), $this); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>品牌</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../script/jquery.validation.min.js"></script>
<script src="../script/my_lightbox.js" language="javascript"></script>
<script language="javascript">
$(function(){
	$('#form').validate({
		errorPlacement: function(error, element){
			element.next('.form-error').append(error);
		},      
		rules : {
			name:{
				required:true
			},
			catid:{
				required:true
			}
		},
		messages : {
			name:{
				required:'请填写品牌'
			},
			catid:{
				required:'请填写国家'
			}
		}
	});
});
//添加品牌时判断品牌是否存在
function checkName(){
    var brandname = $('#name').val();
    var form_error = $('#brand-form-error');
    if(brandname==''){
        form_error.html('品牌名称不能为空');
    }else{
        $.get("<?php echo $this->_tpl_vars['config']['weburl']; ?>
/admin/module.php?m=brand&s=brand.php&operation=checkBrand&brandname="+brandname+"&brandid=<?php echo $this->_tpl_vars['de']['id']; ?>
",function(data){
        	if(data.error){
            	form_error.html(data.msg);
            	$('.submit').attr('disabled','disabled');return false;
            }
        },'json');
    	form_error.html('');
    	$('.submit').attr('disabled','');
    }
}
</script>
</head>
<body>
	<div class="container">
        <div class="flow">
            <div class="itemtitle">
                <h3>品牌</h3>
                <ul>
                    <li <?php if ($_GET['operation'] == ''): ?>class="current"<?php endif; ?>><a href="?m=brand&s=brand.php"><span>管理</span></a></li>
                    <li <?php if ($_GET['operation'] == 'add'): ?>class="current"<?php endif; ?>><a href="?m=brand&s=brand.php&operation=add"><span>添加</span></a></li>
                    <!-- <li <?php if ($_GET['operation'] == 'batch'): ?>class="current"<?php endif; ?>><a href="?m=brand&s=brand.php&operation=batch"><span>批量添加</span></a></li> -->
                    <?php if ($_GET['operation'] == 'edit'): ?>
                    <li class="current"><a href="#"><span>修改</span></a></li>
                    <?php endif; ?>
                    <li><a href="?m=brand&s=brand_cat.php"><span>品牌国家</span></a></li>
                </ul>
            </div>
        </div>
        <div class="h35"></div>  
        <?php if ($_GET['operation'] == 'add' || $_GET['operation'] == 'edit' || $_GET['operation'] == 'batch'): ?>
            <form name="form" id="form" method="post">
            <input name="id" type="hidden" id="id" value="<?php echo $this->_tpl_vars['de']['id']; ?>
">
            <table class="table">
                <thead>
                    <tr>
                        <th class="partition" colspan="99">品牌</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="100">品牌名称</td>
                    <td>
                    <?php if ($_GET['operation'] == 'batch'): ?> 
                    <textarea name="name" id="name" class="w350" rows="10"></textarea>
                    <?php else: ?>
                    <input name="name" id="name" type="text" class="w350" value="<?php echo $this->_tpl_vars['de']['name']; ?>
" onblur="checkName();">
                    <?php endif; ?>
                    <div id="brand-form-error" class="form-error"></div>
                    </td>
                </tr>
                
                 <tr>
                    <td width="100">品牌名称(SEO)</td>
                    <td>
                    <input name="seo_name" id="seo_name" type="text" class="w350" value="<?php echo $this->_tpl_vars['de']['seo_name']; ?>
">
                    <div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                <tr>
                    <td>国家</td>
                    <td>
                    <select class="select" name='catid'>
                    	<option value=''>选择品牌国家</option>
                        <?php $_from = $this->_tpl_vars['cat']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['list']):
?>
                        <option <?php if ($this->_tpl_vars['de']['catid'] == $this->_tpl_vars['list']['id']): ?> selected="selected" <?php endif; ?>value="<?php echo $this->_tpl_vars['list']['id']; ?>
"><?php echo $this->_tpl_vars['list']['catname']; ?>
</option>	
                        <?php $_from = $this->_tpl_vars['list']['scat']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['slist']):
?>
                        <option <?php if ($this->_tpl_vars['de']['catid'] == $this->_tpl_vars['slist']['id']): ?> selected="selected" <?php endif; ?>value="<?php echo $this->_tpl_vars['slist']['id']; ?>
">┣ <?php echo $this->_tpl_vars['slist']['catname']; ?>
</option>	
                        <?php endforeach; endif; unset($_from); ?> 
                        <?php endforeach; endif; unset($_from); ?> 
            		</select>
                    <div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                <tr>
                    <td>LOGO(小)</td>
                    <td>
                    <input name="logo" class="w350" type="text" id="pic" value="<?php echo $this->_tpl_vars['de']['logo']; ?>
" />
                    <input name="oldlogo" type="hidden" value="<?php echo $this->_tpl_vars['de']['logo']; ?>
" />
                    [<a href="javascript:uploadfile('上传LOGO','pic',200,100,'brand')">上传</a>] 
                    [<a href="javascript:preview('pic');">预览</a>]
                    [<a onclick="javascript:$('#pic').val('');" href="#">删除</a>] <span class="bz"></span>
                    </td>
                </tr>
                
                <tr>
                    <td>LOGO(大)</td>
                    <td>
                    <input name="logo_large" class="w350" type="text" id="pic_l_logo" value="<?php echo $this->_tpl_vars['de']['logo_large']; ?>
" />
                    <input name="oldlogo" type="hidden" value="<?php echo $this->_tpl_vars['de']['logo_large']; ?>
" />
                    [<a href="javascript:uploadfile('上传LOGO','pic_l_logo',640,320,'brand')">上传</a>] 
                    [<a href="javascript:preview('pic_l_logo');">预览</a>]
                    [<a onclick="javascript:$('#pic_l_logo').val('');" href="#">删除</a>] <span class="bz"></span>
                    </td>
                </tr>
                
                <tr>
                    <td>图组</td>
                    <td>
                   <div class="product_image">
                <ul id="list1">
                    <?php $_from = $this->_tpl_vars['de']['pic']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['list']):
?>
                        <li id="p<?php echo $this->_tpl_vars['key']+1; ?>
" data-itemid='<?php echo $this->_tpl_vars['key']+1; ?>
'>
                            <div class="product_image_list"> 
                                <div data_type="handle_image">
                                    <div class="image">
                                    <input name="pic[]" type="hidden" id="img<?php echo $this->_tpl_vars['key']; ?>
" value="<?php echo $this->_tpl_vars['list']; ?>
" />
                                    <?php if ($this->_tpl_vars['list']): ?>
                                    <img id="img<?php echo $this->_tpl_vars['key']; ?>
_img" src="<?php echo $this->_tpl_vars['list']; ?>
" width="60">
                                    <?php else: ?>
                                    <img width="60" id="img<?php echo $this->_tpl_vars['key']; ?>
_img" src="<?php echo $this->_tpl_vars['config']['weburl']; ?>
/image/default/nopicsmall.gif"  />
                                    <?php endif; ?>
                                    </div>
                                    <div data_type="handle" class="bg">
                                    <span title="删除" data_type="delete_image">删除</span>
                                    </div>
                                </div>
                                <div class="upload-btn"><a class="upload-button" href="javascript:uploadfile('Style images','img<?php echo $this->_tpl_vars['key']; ?>
',600,600,'brand')">上传</a></div>
                            </div>
                        </li>
                    <?php endforeach; endif; unset($_from); ?>
                    <?php $this->assign('count', count($this->_tpl_vars['de']['pic'])); ?>
                    <?php unset($this->_sections['name']);
$this->_sections['name']['name'] = 'name';
$this->_sections['name']['loop'] = is_array($_loop=$this->_tpl_vars['count']*-1+10) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$this->_sections['name']['show'] = true;
$this->_sections['name']['max'] = $this->_sections['name']['loop'];
$this->_sections['name']['step'] = 1;
$this->_sections['name']['start'] = $this->_sections['name']['step'] > 0 ? 0 : $this->_sections['name']['loop']-1;
if ($this->_sections['name']['show']) {
    $this->_sections['name']['total'] = $this->_sections['name']['loop'];
    if ($this->_sections['name']['total'] == 0)
        $this->_sections['name']['show'] = false;
} else
    $this->_sections['name']['total'] = 0;
if ($this->_sections['name']['show']):

            for ($this->_sections['name']['index'] = $this->_sections['name']['start'], $this->_sections['name']['iteration'] = 1;
                 $this->_sections['name']['iteration'] <= $this->_sections['name']['total'];
                 $this->_sections['name']['index'] += $this->_sections['name']['step'], $this->_sections['name']['iteration']++):
$this->_sections['name']['rownum'] = $this->_sections['name']['iteration'];
$this->_sections['name']['index_prev'] = $this->_sections['name']['index'] - $this->_sections['name']['step'];
$this->_sections['name']['index_next'] = $this->_sections['name']['index'] + $this->_sections['name']['step'];
$this->_sections['name']['first']      = ($this->_sections['name']['iteration'] == 1);
$this->_sections['name']['last']       = ($this->_sections['name']['iteration'] == $this->_sections['name']['total']);
?>
                        <li id="p<?php echo $this->_tpl_vars['key']+$this->_sections['name']['index']+1; ?>
" data-itemid='<?php echo $this->_tpl_vars['key']+$this->_sections['name']['index']+1; ?>
'>
                            <div data_type="handle_image">
                                <div class="image">
                                    <input name="pic[]" type="hidden" id="pic<?php echo $this->_sections['name']['index']; ?>
" value="" />
                                    <img width="60" id="pic<?php echo $this->_sections['name']['index']; ?>
_img" src="<?php echo $this->_tpl_vars['config']['weburl']; ?>
/image/default/nopicsmall.gif"  />
                                </div>
                                <div data_type="handle" class="bg">
                                <span title="删除" data_type="delete_image" class="delete">删除</span>
                                </div>
                            </div>
                            <div class="upload-btn"><a class="upload-button" href="javascript:uploadfile('Style images','pic<?php echo $this->_sections['name']['index']; ?>
',600,600,'brand')">上传</a></div>
                        </li>
                    <?php endfor; endif; ?>
                </ul>
            </div>
                    </td>
                </tr>                
                
                
              <!--   <tr>
                    <td>点击数</td>
                    <td><input type="text" name="hits" value="<?php if ($this->_tpl_vars['de']['hits']): ?><?php echo $this->_tpl_vars['de']['hits']; ?>
<?php else: ?>0<?php endif; ?>" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'')"/></td>
				</tr> -->
				
				
				    <tr>
        <td>品牌故事</td>
                    <td>
        <script charset="utf-8" src="<?php echo $this->_tpl_vars['config']['weburl']; ?>
/lib/kindeditor/kindeditor-min.js"></script>
        <script>
            var editor;
            KindEditor.ready(function(K) {
                editor = K.create('textarea[name="story"]', {});
        });
        </script>
        <textarea name="story" id="story" style="width:100%; height:400px;"><?php echo $this->_tpl_vars['de']['story']; ?>
</textarea>
        </td>
    </tr>
				
				
                
                <tr>
                    <td>状态</td>
                    <td>
                    <input type="radio" name="status" value="2" id="tj" <?php if ($this->_tpl_vars['de']['status'] == 2): ?>checked="checked"<?php endif; ?>/><label for="tj">推荐</label>
                    <input type="radio" name="status" value="1" id="open" <?php if ($this->_tpl_vars['de']['status'] == 1): ?>checked="checked"<?php endif; ?>/><label for="open">开启</label>
                    <input type="radio" name="status" value="0" id="close" <?php if ($this->_tpl_vars['de']['status'] == 0): ?>checked="checked"<?php endif; ?>/><label for="close">关闭</label>
                    </td>
                </tr>
               
                <tr>
                    <td>&nbsp;</td>
                    <td>
                    <input class="submit" type="submit" value="提交">
                    <input name="act" type="hidden" id="action" value="<?php if (! $_GET['editid']): ?><?php if ($_GET['operation'] == 'batch'): ?>batch<?php else: ?>save<?php endif; ?><?php else: ?>edit<?php endif; ?>">
                    </td>
                </tr>
                </tbody>
            </table>
            </form>
            <script type="text/javascript">
            
            function load_pic()
            {
            	$.getScript("<?php echo $this->_tpl_vars['config']['weburl']; ?>
/script/product.js");	
            }
            </script>
            
            
        <?php else: ?>
		<script type="text/javascript">
        $(function(){
            /* 全选 */
             $('.checkall').click(function(){
                var _self = this;
                $('.checkitem').each(function(){
                    if (!this.disabled)
                    {
                        $(this).attr('checked', _self.checked);
                    }
                });
                $('.checkall').attr('checked', this.checked);
            });
        });
        //展示品牌LOGO图片原图
        function showOriginImg(src){
            var ImgDetail = $("#brandLogoDetail");
            ImgDetail.find('img').attr('src',src); 
            ImgDetail.show();
        }
        //隐藏品牌LOGO图片原图
        function hideOriginImg(){
            $("#brandLogoDetail").hide();
        }
        </script>
        <form action="" method="post">
        <table class="table">
        	<thead>
                <tr>
                    <th class="partition" colspan="99">品牌</th>
                </tr>
            </thead>
            <tbody>
                <tr class="header">
                    <th width="30"></th>
                    <th width="70">显示顺序</th>
                    <th width="100">logo</th>
                    <th>品牌名称</th>
                    <th>品牌名称(SEO)</th>
                    <th width="120">国家</th>
                    <th width="100">状态</th>
                    <th width="50"></th>
                </tr>
                <?php $_from = $this->_tpl_vars['de']['list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['list']):
?>
                <tr>
                    <td><input type="checkbox" value="<?php echo $this->_tpl_vars['list']['id']; ?>
" class="checkitem" name="chk[]"></td>
                    <td><input type="text" class="w50" maxlength="3" name="displayorder[<?php echo $this->_tpl_vars['list']['id']; ?>
]" value="<?php echo $this->_tpl_vars['list']['displayorder']; ?>
" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'')" /></td>
                    <td><?php if ($this->_tpl_vars['list']['logo']): ?><img width="40" class="img" src="<?php echo $this->_tpl_vars['list']['logo']; ?>
" onmouseover="javascript:showOriginImg('<?php echo $this->_tpl_vars['list']['logo']; ?>
');" onmouseout="javascript:hideOriginImg();"/><?php else: ?><img class="img" width="40" src="../image/default/nopic.gif" /><?php endif; ?></td>
                    <td><?php echo $this->_tpl_vars['list']['name']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['seo_name']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['catname']; ?>
</td>
                    <td><?php if ($this->_tpl_vars['list']['status'] == 1): ?>开启<?php elseif ($this->_tpl_vars['list']['status'] == 2): ?>推荐<?php else: ?>关闭<?php endif; ?></td>
                    <td>
                    <a href="?m=brand&s=brand.php&operation=edit&editid=<?php echo $this->_tpl_vars['list']['id']; ?>
"><?php echo $this->_tpl_vars['editimg']; ?>
</a> 
                    <a onclick="return confirm('确定删除吗');" href="?m=brand&s=brand.php&delid=<?php echo $this->_tpl_vars['list']['id']; ?>
"><?php echo $this->_tpl_vars['delimg']; ?>
</a>
                    </td>
                </tr>
                <?php endforeach; else: ?>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <?php endif; unset($_from); ?>
            </tbody>
            <tfoot>
                <tr>
                	<td colspan="4">
                        <input type="checkbox" class="checkall" id="del">
                        <input type="hidden" name="act" value="op" />
                        <input type="submit" name="submit" value="<?php echo $this->_tpl_vars['lang']['btn_submit']; ?>
" />
                        <input type="submit" name="submit" value="<?php echo $this->_tpl_vars['lang']['rc']; ?>
" />
                        <input type="submit" name="submit" value="<?php echo $this->_tpl_vars['lang']['btn_open']; ?>
" />
                        <input type="submit" name="submit" value="<?php echo $this->_tpl_vars['lang']['btn_close']; ?>
" />
                    </td>
                    <td colspan="99"><div class="page"><?php echo $this->_tpl_vars['de']['page']; ?>
</div></td>
                </tr>
            </tfoot>
        </table>
        </form>
        <div id="brandLogoDetail" align="center" style="position:fixed;top:30%;left:30%;display:none;"><img width="200" height="100" src="" onerror="this.src='../image/admin/sns_img_fail_min.jpg'" /></div>
        <?php endif; ?>
    </div>
</body>
</html>